<template>
	<view class="big">
		<view class="search">
			<input class="search_in" v-model="search" type="text" value="" @input="messagesearch" placeholder="通过名字搜索通知"/>
			<view class="search_but">
				<button type="default">搜索</button>
			</view>
		</view>
		<view class="fg"><view></view></view>
		<view class="bhome">
			<view class="bigbox" style="overflow:auto;">
				<!-- <block v-for="(item,index) in res.data.data">
					<view class="item">
						<view class="info">
							<view class="activity_title">{{item.name}}</view>
							<view class="activity_resp">
								<view class="title">负责单位</view>{{item.id}}
							</view>
							<view class="activity_deadline">
								<view class="title">招募截至</view>{{item.endTime}}
							</view>
						</view>
							
						<view class="item_btn">
							<view class="apply">
								<navigator @click="joinActive(item)">报名</navigator>
							</view>
							<view class="detail">
								<navigator :url="'./huodong_detail?id='+item.id">详情</navigator>
							</view>
						</view>
					</view>
				</block> -->
				<block v-for="(item,index) in res.data.data">
					<view class="item">
						<view class="info">
							<view class="activity_title">{{item.name}}</view>
							<view class="activity_resp">
								<view class="title">通知年级</view>{{item.grade}}
							</view>
							<view class="activity_deadline">
								<view class="title">通知类型</view>{{item.infoType}}
							</view>
						</view>
							
						<view class="item_btn">
							<view class="apply">
								<navigator @click="delNotice(item)">删除</navigator>
							</view>
							<view class="detail">
								<navigator :url="'./tongzhi_detail?id='+item.id">详情</navigator>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>


<script>
	// import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
	export default {
		data() {
			return {
				curr:0,
				res:{},
				pes:{},
				timer:null,
				name:'',
				phone:'',
				type:'123',
				centent:'',
				beginTime:'',
				endTime:'',
				sponsor:'',
			}
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res) => {
					// let height = res.windowHeight - uni.upx2px(100)
					// this.swiperheight = height;
				}
			})
			uni.request({
				url:'http://120.77.247.146:8080/admin/noticeList',
				method:'POST',
				success: (res) => {
					this.res=res,
					console.log(res)
				}
			})
		},
		methods: {
			recruit(){
				if(this.name==''){
					uni.showToast({
						title:'标题不能为空',
						icon:'error',
					})
				}
				else if(this.beginTime==''||this.endTime==''){
					uni.showToast({
						title:'时间不能为空',
						icon:'error',
					})
				}
				else if(this.sponsor==''){
					uni.showToast({
						title:'负责单位不能为空',
						icon:'error',
					})
				}
				else if(this.phone==''){
					uni.showToast({
						title:'联系方式不能为空',
						icon:'error',
					})
				}
				else if(this.centent==''){
					uni.showToast({
						title:'详情内容不能为空',
						icon:'error',
					})
				}
				else{
					// var kes={"beginTime": this.beginTime,
					// 		  "content": this.centent,
					// 		  "endTime": this.endTime,
					// 		  "id": 0,
					// 		  "name": this.name,
					// 		  "phone": this.phone,
					// 		  "place": "none",
					// 		  "sponsor": this.sponsor,
					// 		  "type": this.type};
					// console.log(kes);
					uni.getStorage({
						key:'student',
						success: (no) => {
							this.no=no.data.no,
							console.log(this.no+"!!!!!!!"),
							uni.request({
								url:'http://124.222.175.145:8080/recruitingPlayers/publishPlayers',
								method:'POST',
								data:{
									  "beginTime": this.beginTime,
									  "content": this.centent,
									  "endTime": this.endTime,
									  "id": 0,
									  "name": this.name,
									  "phone": this.phone,
									  "place": "none",
									  "sponsor": this.sponsor,
									  "type": this.type,
									  "no":this.no
									},
								success: (pes) => {
									this.pes=pes,
									console.log(this.pes)
								}
							})
						}
					})
					
					console.log('成功发布')
				}
			},
			refresh(){
				uni.request({
					url:'http://124.222.175.145:8080/recruitingPlayers/finAll',
					success: (res) => {
						this.res=res,
						console.log("刷新了")
					}
				})
			},
			open() {
				this.$refs.calendar.open();
			},
			open1() {
				this.$refs.calendar1.open();
			},
			confirm(e) {
				this.beginTime = e.fulldate
			},
			confirm1(e){
				this.endTime = e.fulldate
			},
			delNotice(item){
				// this.no=s.data.no,
				uni.showModal({
					title:'提示',
					content:'确定删除吗？',
					success: (sn) => {
						if(sn.confirm){
							uni.request({
								url:'http://120.77.247.146:8080/admin/deleteActive',
								method:'POST',
								data:{
								  // "beginTime": item.beginTime,
								  //   "content": item.content,
								  //   "endTime": item.endTime,
									"id": item.id,
									// "name": item.name,
									// "no": s.data.no,
									// "phone": item.phone,
									// "place": item.place,
									// "sponsor": item.sponsor,
									// "type": item.type
								},
								success: (rp) => {
									uni.showToast({
										title:"删除成功"
									}),
									uni.request({
										url:'http://120.77.247.146:8080/admin/noticeList',
										method:'POST',
										success: (res) => {
											this.res=res,
											console.log(res)
										}
									})
								}
							})
						}
					}
				})
			},
			setCurr(e) {
			// console.log(e.detail.current)
			let thisCurr = e.detail.current || e.currentTarget.dataset.index || 0;
			// console.log(thisCurr)
			this.curr = thisCurr;
			},
			messagesearch(event){
				console.log(event.target.value);
				uni.request({
					url:'http://120.77.247.146:8080/admin/searchNotice',
					method:'POST',
					data:{
						"name":event.target.value,
					},
					success: (res) => {
						this.res={},
						console.log(res),
						this.res=res
					}
				})
			},
		}
	}
</script>
<style>
	input{
		border: 1rpx solid #000000;
	}
	.bigbox1{
		height: 100%;
		width: 100%;
		padding: 0;
		margin: 0;
		background-color: #f8f8f8;
		/* overflow:hidden; */
	}
	.time_and_unit{
		border-radius: 20rpx;
		background-color: white;
	}
	.bhome{
		margin-top: 10rpx;
		height: 92%;
	}
	.fg{
		width: 100%;
		margin: 0;
		margin-top: 18rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.fg view{
		background-color: #8c8c8c;
		height: 1rpx;
		width: 96%;
	}
	.bigbox{
		position: fixed;
		width: 100%;
		height: 95%;
	}
	.bigbox .item{
		display: flex;
		padding: 25rpx 0;
		border-bottom: 2rpx #eee solid;
		padding-left: 30rpx;
	}
	.bigbox .item:last-child{
		margin-bottom: 100rpx;
	}
	.bigbox .item .info{
		flex: 1;
	}
	.bigbox .item .activity_title{
		font-size: 36rpx;
		color: #212121;
		padding-bottom: 20rpx;
		font-weight: 600;
	}
	.bigbox .item .activity_deadline,
	.bigbox .item .activity_resp
	{
		color: #424242;
		font-size: 30rpx;
		margin-bottom: 10rpx;
	}
	.bigbox .item .activity_deadline .title,
	.bigbox .item .activity_resp .title{
		display: inline-block;
		color: #616161;
		margin-right: 30rpx;
	}
	.bigbox .item .item_btn{
		display: flex;
		flex-direction: column;
		height: 100%;
		justify-content: center;
	}
	.bigbox .item .item_btn .apply navigator,
	.bigbox .item .item_btn .detail navigator{
		display: inline-block;
		padding: 10rpx 23rpx;
		border-radius: 3px;
		background-color: #ff4d4d;
		margin-top: 20rpx;
		margin-right: 30rpx;
		color: #fff;
		font-size: 25rpx;
	}
	.bigbox .item .item_btn .detail navigator{
		background-color: #fff;
		border: 2rpx solid #2196F3;
		color: #2196F3;
	}
	
	.big{
		/* background-image: url('https://pic.imgdb.cn/item/626e354a239250f7c51d1390.jpg'); */
		width: 100%;
		height: 100%;
		background-repeat: no-repeat;
		background-size: cover;
		-webkit-background-size: cover;
		-o-background-size: cover;
		background-position: center 0;
	}
	.Vertical_line{
		background-color: black;
		width: 1rpx;
		height: 35%;
		margin: 0 6rpx 0 6rpx;
		opacity: 0;
	}
	.detail{
		color: #007AFF;
	}
	.startzhaomu button{
		text-align: center;
		width: 500rpx;
		color: #ffffff;
		margin-top: 50rpx;
		background-color: #007AFF;
	}
	.nameInput{
		height: 60rpx;
		font-size: 38rpx;
		width: 80%;
		overflow: auto;
	}
	.details{
		/* margin-top: 50rpx; */
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.details textarea{
		color: #000000;
		width: 80%;
		height: 1000rpx;
		overflow: auto;
	}
	.second_box{
		width: 100%;
		/* height: 5%; */
		display: flex;
		justify-content: center;
		/* position: fixed; */
		/* height: 12%; */
		background-color: rgb(244,244,244);
		margin: 0;
		margin-top: 1%;
	}
	.third_box{
		width: 24%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		text-align: center;
	}
	.second_box_third{
		height: 100rpx;
		width: 98%;
		/* background-color: #3ECCCC; */
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.search{
		background-color: #ffffff;
		height: 6%;
		width: 100%;
		display: flex;
		margin: 0;
		justify-content: center;
		align-items: center;
	}
	.search input{
		border-top-left-radius: 12rpx;
		border-bottom-left-radius: 12rpx;
		width: 70%;
		border: 4rpx solid #2196F3;
	}
	.search_in{
		height: 70rpx;
		width: 100%;
		margin: 0;
		padding: 0;
		/* background-color: red; */
	}
	.search_but{
		background-color: #2196F3;
		border-top-right-radius: 12rpx;
		border-bottom-right-radius: 12rpx;
	}
	.search .search_but button{
		background-color: #2196F3;
		margin: 0;
		padding: 0;
		width:80px;
		height:78rpx; 
		color:white;
		font-size: 16px;
	}
	.search button.active{
		
	}
	.title{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 20rpx;
	}
	.unit{
		width: 100%;
		display: flex;
	}
	.cent{
		width: 100%;
		display: flex;
		margin-top: 50rpx;
	}
	.lab{
		width: 30%;
		color: #757575;
		margin-right: 30rpx;
		/* float: right; */
	}
	.ins{
		width:70%;
		display: flex;
	}
	.bgtime,.edtime{
		width: 190rpx;
	}
	.time{
		display: flex;
	}
	.lab label{
		float: right;
	}
	textarea{
		
		border:1rpx solid #000000;
	}
	.trade{
		width: 100%;
		color: #000000;
		display: flex;
		overflow: auto; 
	}
	.trade view{
		height: auto;
		text-align: center;
		width: 50%;
		float: left;
	}
	.trade .texts.active{
		border-bottom: 8upx solid #2196F3;
	}
</style>

